package com.example.myapplication.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class PreferenceUtlis {

    private SharedPreferences preferences;
    private static  PreferenceUtlis Instance = null;
    public static  final String ISLOGIN ="IS_LOGIN";
    public static  final String USERNAME ="USER_NAME";
    private PreferenceUtlis(Context ctx){
        preferences = ctx.getSharedPreferences( "pussy",Context.MODE_PRIVATE );
    }

    public static PreferenceUtlis getInstance(Context ctx){
        if (Instance != null){
            return Instance;
        }
        Instance = new PreferenceUtlis(ctx);
        return Instance;
    }
    public boolean readLogin (){
        return preferences.getBoolean( ISLOGIN   ,false);
    }
    public String readname (){
        return preferences.getString( USERNAME  ,"");
    }

    public void savereadLogin (boolean islogin , String username){
        preferences.edit().putBoolean( ISLOGIN , islogin ).apply();
        preferences.edit().putString( USERNAME , username ).apply();
    }
}
